<style scoped src="./index.scss" lang="scss" rel="stylesheet/scss"></style>
<template src="./index.html"></template>
<script>

export default {
  props: ["value","imgUrl","types"],
  mixins: [Vue.prototype.$vFN.Utils],
  components: {},
  data() {
    return {
      show: true,

      wxAppletUrl: null,
      wxAppletTips: "加载中",
      
      imgUrl: "", // 体验二维码
    };
  },
  methods: {

    // 按钮
    button(value){
      this.$emit('click',value);
    },
    
    // 获取体验二维码
   async barcode(){
      this.show = false;

      let _data = await this.$vFN.Http.post(
                {
                    url: "mall-site-portal/wechat-ma-audit/getTestQrcode",
                    data: {
                      templateId: this.value.auditDetails.templateId,
                    }
                },
        window
      );

      if(_data._ok){
        this.imgUrl = _data.data;
      }

    },

    // 获取小程序二维码
    async getMiniAppCode() {

      let res = await this.$vFN.Http.post({
                url: "mall-site-portal/qrcode/getUnlimited",
                isErrorAlert: false,
                data: {
                    width: 500,
                    page: "pages/index/index",
                    hyaline: true,
                    lineColor: {
                        r: 0,
                        g: 0,
                        b: 0,
                    },
                    autoColor: false,
                    scene: 0,
                },
            },
            window
        );

        if (res.code == 200) {
              this.wxAppletUrl = res.data;
        } else {
              this.wxAppletTips = res.data.message;
        }
    },

    // 时间戳转换
    timeStamp(time){
      if(!this.$vFN.Utils.isEmpty(time)){
        return  this.$vFN.Utils.timestampToDate('yyyy-MM-dd HH:mm:ss',time * 1000)
      }
    },

  },
  mounted() {},
  watch: {
            "value": {
                handler(newName, oldName) {
                     // 是否发布了小程序
                    if(newName.releaseDetails){
                      this.getMiniAppCode();
                    }
                },
                immediate: true,
                deep: true,
            }
  },

  activated() {
  },
};
</script>